package org.xteam.box2text;

public class Point {

	private int x;
	private int y;

	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	public int x() {
		return x;
	}
	
	public int y() {
		return y;
	}
	
	public int width() {
		return x();
	}
	
	public int height() {
		return y();
	}
	
	public String toString() {
		return "(" + x + "," + y + ")";
	}

	public boolean isZero() {
		return x == 0 && y == 0;
	}
	
	public Point v(Point p2) {
		if (p2.isZero())
			return this;
		if (isZero())
			return p2;
		return new Point(p2.width(), height() + 1 + p2.height());
	}
	
	public Point h(Point p2, int hs) {
		if (p2.isZero())
			return this;
		if (this.isZero())
			return p2;
		return new Point(width() + hs + p2.width(), height() + p2.height());
	}
	
	public Point hov(Point p2, int hs) {
		if (p2.isZero())
			return this;
		if (isZero())
			return p2;
		if (height() == 0 && p2.height() == 0) {
			return new Point(width() + hs + p2.width(), 0);
		}
		return new Point(p2.width(), height() + p2.height());
	}
	
	public Point hv(Point p2, int hs) {
		if (p2.isZero())
			return this;
		if (p2.height() == 0) {
			return new Point(width() + hs + p2.width(), height());
		}
		return new Point(p2.width(), height() + 1 + p2.height());
	}

}
